#include <assert.h>
#include "scene.h"
#include "ctrlboard.h"
#include "mg_Lcd_Driver.h"
#include "mg_Device.h"
#include "mg_Rs485Protocol.h"
#include "mg_Rotate.h"
//#ifdef WIN32
//#pragma execution_character_set("utf-8")
//#endif
/* widgets:
Layer_MainMenu
Background_Mainmenu
CoverFlow_Mainmenu
Container_MainMenu11
Text_MM_Page11
Text_MM_11_State
Text_MM_11_Name2
Text_MM_11_Name1
PopupButton_MainMenu11
Container_MainMenu10
Text_MM_Page10
Text_MM_10_State
Text_MM_10_Name2
Text_MM_10_Name1
PopupButton_MainMenu10
Container_MainMenu9
Text_MM_Page9
Text_MM_9_State
Text_MM_9_Name2
Text_MM_9_Name1
PopupButton_MainMenu9
Container_MainMenu8
Text_MM_Page8
Text_MM_8_State
Text_MM_8_Name2
Text_MM_8_Name1
PopupButton_MainMenu8
Container_MainMenu7
Text_MM_Page7
Text_MM_7_State
Text_MM_7_Name2
Text_MM_7_Name1
PopupButton_MainMenu7
Container_MainMenu6
Text_MM_Page6
Text_MM_6_State
Text_MM_6_Name2
Text_MM_6_Name1
PopupButton_MainMenu6
Container_MainMenu5
Text_MM_Page5
Text_MM_5_State
Text_MM_5_Name2
Text_MM_5_Name1
PopupButton_MainMenu5
Container_MainMenu4
Text_MM_Page4
Text_MM_4_State
Text_MM_4_Name2
Text_MM_4_Name1
PopupButton_MainMenu4
Container_MainMenu3
Text_MM_Page3
Text_MM_3_State
Text_MM_3_Name2
Text_MM_3_Name1
PopupButton_MainMenu3
Container_MainMenu2
Text_MM_Page2
Text_MM_2_State
Text_MM_2_Name2
Text_MM_2_Name1
PopupButton_MainMenu2
Container_MainMenu1
Text_MM_Page1
Text_MM_1_State
Text_MM_1_Name2
Text_MM_1_Name1
PopupButton_MainMenu1
*/


static ITUBackground* Background_Mainmenu;
static ITUCoverFlow* CoverFlow_Mainmenu;
static ITUContainer* Container_MainMenu[DeviceNumMax];
static ITUPopupButton* PopupButton_MainMenu[DeviceNumMax];
static ITUText* Text_MM_Name1[DeviceNumMax];
static ITUText* Text_MM_Name2[DeviceNumMax];
static ITUText* Text_MM_State[DeviceNumMax];
static ITUText* Text_MM_Page[DeviceNumMax];
static ITUText* Text_MM_Setting;
static bool Is_HaveDevice = false;
bool MainMenuOnEnter(ITUWidget* widget, char* param)
{
	bool ret;
	uint8_t i, PageNum_D = 0;
	char PageNum[3], Page[10];
	char DeviceState_Text[20];
	char TempName[64], TempNum[64];
	UTF8_TWO_LINE DeviceTempName;
	if (!Background_Mainmenu)
	{
		Background_Mainmenu = ituSceneFindWidget(&theScene, "Background_Mainmenu");
		assert(Background_Mainmenu);
		CoverFlow_Mainmenu = ituSceneFindWidget(&theScene, "CoverFlow_Mainmenu");
		assert(CoverFlow_Mainmenu);
		for (i = 0; i < DeviceNumMax; i++)//加载小部件
		{
			//Container
			strcpy(TempName, "Container_MainMenu");
			strcat(TempName, itoa(i, TempNum, 10));
			Container_MainMenu[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Container_MainMenu[i]);
			//PopupButton
			strcpy(TempName, "PopupButton_MainMenu");
			strcat(TempName, itoa(i, TempNum, 10));
			PopupButton_MainMenu[i] = ituSceneFindWidget(&theScene, TempName);
			assert(PopupButton_MainMenu[i]);
			//Text_MM_Name1
			strcpy(TempName, "Text_MM_Name1_");
			strcat(TempName, itoa(i, TempNum, 10));
			Text_MM_Name1[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Text_MM_Name1[i]);
			//Text_MM_Name2
			strcpy(TempName, "Text_MM_Name2_");
			strcat(TempName, itoa(i, TempNum, 10));
			Text_MM_Name2[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Text_MM_Name2[i]);
			//Text_MM_State
			strcpy(TempName, "Text_MM_State");
			strcat(TempName, itoa(i, TempNum, 10));
			Text_MM_State[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Text_MM_State[i]);
			//Text_MM_Page
			strcpy(TempName, "Text_MM_Page");
			strcat(TempName, itoa(i, TempNum, 10));
			Text_MM_Page[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Text_MM_Page[i]);
		}
		Text_MM_Setting = ituSceneFindWidget(&theScene, "Text_MM_Setting");
		assert(Text_MM_Setting);
	}
	ituWidgetSetVisible(CoverFlow_Mainmenu, false);//设置为隐藏
	for (i = 1; i <= DeviceNumMax; i++)//获取总页数
	{
		if (TFT_Device[i].DeviceIsAllocation == true)
			PageNum_D++;
	}
	itoa(PageNum_D, PageNum, 10);//将总页数转成字符串
	//对每个按键进行编辑
	Is_HaveDevice = false;
	PageNum_D = 0;//页码归零
	for (i = 1; i <= DeviceNumMax; i++)
	{
		if (Sys.Language == MG_LANGUAGE_CHS)
		{
			Text_MM_Name1[i - 1]->fontIndex = 5;
			Text_MM_Name1[i - 1]->boldSize = 1;
			ituTextSetFontSize(Text_MM_Name1[i - 1], 30);
			ituWidgetSetY(Text_MM_Name1[i - 1], 84);
			Text_MM_Name2[i - 1]->fontIndex = 5;
			Text_MM_Name2[i - 1]->boldSize = 1;
			ituTextSetFontSize(Text_MM_Name2[i - 1], 30);
			ituWidgetSetY(Text_MM_Name2[i - 1], 116);
			Text_MM_State[i - 1]->fontIndex = 1;
			Text_MM_State[i - 1]->boldSize = 1;
			ituTextSetFontSize(Text_MM_State[i - 1], 19);
			ituWidgetSetY(Text_MM_State[i - 1], 46);
			Text_MM_Page[i - 1]->fontIndex = 1;
			Text_MM_Page[i - 1]->boldSize = 1;
			ituTextSetFontSize(Text_MM_Page[i - 1], 15);
			ituWidgetSetY(Text_MM_Page[i - 1], 164);

		}
		else if (Sys.Language == MG_LANGUAGE_ENG)
		{
			Text_MM_Name1[i - 1]->fontIndex = 4;
			Text_MM_Name1[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM_Name1[i - 1], 22);
			ituWidgetSetY(Text_MM_Name1[i - 1], 88);
			Text_MM_Name2[i - 1]->fontIndex = 4;
			Text_MM_Name2[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM_Name2[i - 1], 22);
			ituWidgetSetY(Text_MM_Name2[i - 1], 112);
			Text_MM_State[i - 1]->fontIndex = 7;
			Text_MM_State[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM_State[i - 1], 15);
			ituWidgetSetY(Text_MM_State[i - 1], 50);
			Text_MM_Page[i - 1]->fontIndex = 7;
			Text_MM_Page[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM_State[i - 1], 15);
			ituWidgetSetY(Text_MM_Page[i - 1], 160);
		}
		else if (Sys.Language == MG_LANGUAGE_ZHTW)
		{
			Text_MM_Name1[i - 1]->fontIndex = 8;
			Text_MM_Name1[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM_Name1[i - 1], 24);
			ituWidgetSetY(Text_MM_Name1[i - 1], 84);
			Text_MM_Name2[i - 1]->fontIndex = 8;
			Text_MM_Name2[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM_Name2[i - 1], 24);
			ituWidgetSetY(Text_MM_Name2[i - 1], 116);
			Text_MM_State[i - 1]->fontIndex = 8;
			Text_MM_State[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM_State[i - 1], 12);
			ituWidgetSetY(Text_MM_State[i - 1], 46);
			Text_MM_Page[i - 1]->fontIndex = 8;
			Text_MM_Page[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM_Page[i - 1], 12);
			ituWidgetSetY(Text_MM_Page[i - 1], 164);
		}

		if (TFT_Device[i].DeviceIsAllocation == true)
		{
			Is_HaveDevice = true;
			PageNum_D++;
			printf("Device No.%d : \n", i);
			//设备是否显示
			ituWidgetSetVisible(Container_MainMenu[i - 1], true);//设置为显示
			if (TFT_Device[i].DeviceEventType == 1)//设备名称拆解
				DeviceTempName = Get_UTF8_Two_Line(TFT_Device[i].TFTSCEQ.TFT_Device.DeviceName, TFT_Device[i].TFTSCEQ.TFT_Device.DeviceNameLen);//获取合理的换行字符串
			else//场景名称拆解
				DeviceTempName = Get_UTF8_Two_Line(TFT_Device[i].TFTSCEQ.TFT_Scene.DeviceName, TFT_Device[i].TFTSCEQ.TFT_Scene.DeviceNameLen);//获取合理的换行字符串
			ituTextSetString(Text_MM_Name1[i - 1], DeviceTempName.DeviceName1); 
			ituTextSetString(Text_MM_Name2[i - 1], DeviceTempName.DeviceName2);
			if (strlen(DeviceTempName.DeviceName2) == 0)//单行字母
			{
				if (Sys.Language == MG_LANGUAGE_CHS)
					ituWidgetSetY(Text_MM_Name1[i - 1], 96);
				else if (Sys.Language == MG_LANGUAGE_ENG)
					ituWidgetSetY(Text_MM_Name1[i - 1], 100);
			}
			printf("Name : %s\n", TFT_Device[i].TFTSCEQ.TFT_Device.DeviceName);
			//设备状态显示
			GetText_DeviceState(i, DeviceState_Text);
			ituTextSetString(Text_MM_State[i - 1], DeviceState_Text);
			printf("State : %s\n", DeviceState_Text);
			//页码显示
			itoa(PageNum_D, Page, 10);
			strcat(Page, "/");
			strcat(Page, PageNum);
			ituTextSetString(Text_MM_Page[i - 1], Page);
			printf("Page : %s\n", Page);
		}
		else
		{
			printf("Device No.%d is not exist! \n", i);
			ituWidgetSetVisible(Container_MainMenu[i - 1], false);//设置为隐藏
		}
	}
	if (Is_HaveDevice == false)//没有设备
	{
		ituWidgetSetVisible(Container_MainMenu[0], true);//设置为显示
		ituTextSetString(Text_MM_State[0], "");
		if (Sys.Language == MG_LANGUAGE_CHS)
		{
			ituTextSetString(Text_MM_Name1[0], "暂未");
			ituTextSetString(Text_MM_Name2[0], "配置");
		}
		else if (Sys.Language == MG_LANGUAGE_ENG)
		{
			ituTextSetString(Text_MM_Name1[0], "Not");
			ituTextSetString(Text_MM_Name2[0], "configured");
		}
		else if (Sys.Language == MG_LANGUAGE_ZHTW)
		{
			ituTextSetString(Text_MM_Name1[0], "暫未");
			ituTextSetString(Text_MM_Name2[0], "配置");
		}
		ituTextSetString(Text_MM_Page[0], "1/1");
		ituCoverFlowGoto(CoverFlow_Mainmenu, 0);
	}
	if (Sys.Language == MG_LANGUAGE_CHS)
	{
		Text_MM_Setting->fontIndex = 5;
		Text_MM_Setting->boldSize = 1;
		ituTextSetFontSize(Text_MM_Setting, 25);
		ituWidgetSetY(Text_MM_Setting, 100);
		ituWidgetSetX(Text_MM_Setting, 69);
	}
	else if (Sys.Language == MG_LANGUAGE_ENG)
	{
		Text_MM_Setting->fontIndex = 4;
		Text_MM_Setting->boldSize = 0;
		ituTextSetFontSize(Text_MM_Setting, 22);
		ituWidgetSetY(Text_MM_Setting, 102);
		ituWidgetSetX(Text_MM_Setting, 67);
	}
	else if (Sys.Language == MG_LANGUAGE_ZHTW)
	{
		Text_MM_Setting->fontIndex = 8;
		Text_MM_Setting->boldSize = 0;
		ituTextSetFontSize(Text_MM_Setting, 24);
		ituWidgetSetY(Text_MM_Setting, 103);
		ituWidgetSetX(Text_MM_Setting, 68);
	}
	ituWidgetSetVisible(CoverFlow_Mainmenu, true);//设置为显示
	ituWidgetSetVisible(Background_Mainmenu, true);//设置为显示
	Set_Rotate_Block(120);//设置间隔刻度
	return true;
}

bool MainMenuOnLeave(ITUWidget* widget, char* param)
{
	ituWidgetSetVisible(Background_Mainmenu, false);//设置为隐藏
    return true;
}

bool MainMenuOnTimer(ITUWidget* widget, char* param)
{
	static uint8_t TempIndex = 1;
	uint8_t i, PageNum_D = 0;
	char PageNum[3], Page[10];
	char DeviceState_Text[20];
	UTF8_TWO_LINE DeviceTempName;

	//用户操作
	if (Action_Cmd.User_Action == Left_Slide || Action_Cmd.User_Action == Anticlockwise_Rotation)
	{
		if (CoverFlowCheckIdle(CoverFlow_Mainmenu))
		{
			ituCoverFlowPrev(CoverFlow_Mainmenu);
		}
		Clear_User_Action();
	} 
	else if (Action_Cmd.User_Action == Right_Slide || Action_Cmd.User_Action == Clockwise_Rotation)
	{
		if (CoverFlowCheckIdle(CoverFlow_Mainmenu))
		{
			ituCoverFlowNext(CoverFlow_Mainmenu);
		}
		Clear_User_Action();
	}

	//滑动检查，获取当前界面状态
	DisplayValue.TFT_Display_Device = CoverFlow_Mainmenu->focusIndex + 1;
	if (DisplayValue.TFT_Display_Device != TempIndex)
	{
		MessageFlag[MSG_GET_DEVICE_STATE] = ON;
		MessageFlag[MSG_GET_DEVICE_CONFIG] = ON;
		TempIndex = DisplayValue.TFT_Display_Device;
	}
		
	//设备具体状态显示
	if (MessageFlag[MSG_GUI_STATE_UPDATE] == ON)
	{
		for (i = 1; i <= DeviceNumMax; i++)
		{
			if (TFT_Device[i].DeviceIsAllocation == true)
			{
				//设备状态显示
				GetText_DeviceState(i, DeviceState_Text);
				ituTextSetString(Text_MM_State[i - 1], DeviceState_Text);
			}
		}
		MessageFlag[MSG_GUI_STATE_UPDATE] = OFF;
	}
	//设备配置更新
	if (MessageFlag[MSG_GUI_CONFIG_UPDATE] == ON)
	{
		ituWidgetSetVisible(CoverFlow_Mainmenu, false);//设置为隐藏
		PageNum_D = 0;
		for (i = 1; i <= DeviceNumMax; i++)//获取总页数
		{
			if (TFT_Device[i].DeviceIsAllocation == true)
				PageNum_D++;
		}
		itoa(PageNum_D, PageNum, 10);//将总页数转成字符串
		//对每个按键进行编辑
		Is_HaveDevice = false;
		PageNum_D = 0;//页码归零
		for (i = 1; i <= DeviceNumMax; i++)
		{
			if (Sys.Language == MG_LANGUAGE_CHS)
			{
				Text_MM_Name1[i - 1]->fontIndex = 5;
				Text_MM_Name1[i - 1]->boldSize = 1;
				ituTextSetFontSize(Text_MM_Name1[i - 1], 30);
				ituWidgetSetY(Text_MM_Name1[i - 1], 84);
				Text_MM_Name2[i - 1]->fontIndex = 5;
				Text_MM_Name2[i - 1]->boldSize = 1;
				ituTextSetFontSize(Text_MM_Name2[i - 1], 30);
				ituWidgetSetY(Text_MM_Name2[i - 1], 116);
				Text_MM_State[i - 1]->fontIndex = 1;
				Text_MM_State[i - 1]->boldSize = 1;
				ituTextSetFontSize(Text_MM_State[i - 1], 19);
				ituWidgetSetY(Text_MM_State[i - 1], 46);
				Text_MM_Page[i - 1]->fontIndex = 1;
				Text_MM_Page[i - 1]->boldSize = 1;
				ituTextSetFontSize(Text_MM_Page[i - 1], 15);
				ituWidgetSetY(Text_MM_Page[i - 1], 164);
			}
			else if (Sys.Language == MG_LANGUAGE_ENG)
			{
				Text_MM_Name1[i - 1]->fontIndex = 4;
				Text_MM_Name1[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM_Name1[i - 1], 22);
				ituWidgetSetY(Text_MM_Name1[i - 1], 88);
				Text_MM_Name2[i - 1]->fontIndex = 4;
				Text_MM_Name2[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM_Name2[i - 1], 22);
				ituWidgetSetY(Text_MM_Name2[i - 1], 112);
				Text_MM_State[i - 1]->fontIndex = 7;
				Text_MM_State[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM_State[i - 1], 15);
				ituWidgetSetY(Text_MM_State[i - 1], 50);
				Text_MM_Page[i - 1]->fontIndex = 7;
				Text_MM_Page[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM_Page[i - 1], 15);
				ituWidgetSetY(Text_MM_Page[i - 1], 160);
			}
			else if (Sys.Language == MG_LANGUAGE_ZHTW)
			{
				Text_MM_Name1[i - 1]->fontIndex = 8;
				Text_MM_Name1[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM_Name1[i - 1], 24);
				ituWidgetSetY(Text_MM_Name1[i - 1], 84);
				Text_MM_Name2[i - 1]->fontIndex = 8;
				Text_MM_Name2[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM_Name2[i - 1], 24);
				ituWidgetSetY(Text_MM_Name2[i - 1], 116);
				Text_MM_State[i - 1]->fontIndex = 8;
				Text_MM_State[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM_State[i - 1], 12);
				ituWidgetSetY(Text_MM_State[i - 1], 46);
				Text_MM_Page[i - 1]->fontIndex = 8;
				Text_MM_Page[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM_Page[i - 1], 12);
				ituWidgetSetY(Text_MM_Page[i - 1], 164);
			}
			if (TFT_Device[i].DeviceIsAllocation == true)
			{
				Is_HaveDevice = true;
				PageNum_D++;
				ituWidgetSetVisible(Container_MainMenu[i - 1], true);//设置为显示
				if (TFT_Device[i].DeviceEventType == 1)//设备名称拆解
					DeviceTempName = Get_UTF8_Two_Line(TFT_Device[i].TFTSCEQ.TFT_Device.DeviceName, TFT_Device[i].TFTSCEQ.TFT_Device.DeviceNameLen);//获取合理的换行字符串
				else//场景名称拆解
					DeviceTempName = Get_UTF8_Two_Line(TFT_Device[i].TFTSCEQ.TFT_Scene.DeviceName, TFT_Device[i].TFTSCEQ.TFT_Scene.DeviceNameLen);//获取合理的换行字符串
				ituTextSetString(Text_MM_Name1[i - 1], DeviceTempName.DeviceName1);
				ituTextSetString(Text_MM_Name2[i - 1], DeviceTempName.DeviceName2);
				if (strlen(DeviceTempName.DeviceName2) == 0)//单行字母
				{
					if (Sys.Language == MG_LANGUAGE_CHS)
						ituWidgetSetY(Text_MM_Name1[i - 1], 96);
					else if (Sys.Language == MG_LANGUAGE_ENG)
						ituWidgetSetY(Text_MM_Name1[i - 1], 100);
				}
				//设备状态显示
				ituTextSetString(Text_MM_State[i - 1], "");
				//页码显示
				itoa(PageNum_D, Page, 10);
				strcat(Page, "/");
				strcat(Page, PageNum);
				ituTextSetString(Text_MM_Page[i - 1], Page);
			}
			else
				ituWidgetSetVisible(Container_MainMenu[i - 1], false);//设置为隐藏
		}
		if (Is_HaveDevice == false)//没有设备
		{
			ituWidgetSetVisible(Container_MainMenu[0], true);//设置为显示
			ituTextSetString(Text_MM_State[0], "");
			if (Sys.Language == MG_LANGUAGE_CHS)
			{
				ituTextSetString(Text_MM_Name1[0], "暂未");
				ituTextSetString(Text_MM_Name2[0], "配置");
			}
			else if (Sys.Language == MG_LANGUAGE_ENG)
			{
				ituTextSetString(Text_MM_Name1[0], "Not");
				ituTextSetString(Text_MM_Name2[0], "configured");
			}
			else if (Sys.Language == MG_LANGUAGE_ZHTW)
			{
				ituTextSetString(Text_MM_Name1[0], "暫未");
				ituTextSetString(Text_MM_Name2[0], "配置");
			}
			ituTextSetString(Text_MM_Page[0], "1/1");
			ituCoverFlowGoto(CoverFlow_Mainmenu, 0);
		}
		ituWidgetSetVisible(CoverFlow_Mainmenu, true);//设置为显示
		MessageFlag[MSG_GUI_CONFIG_UPDATE] = OFF;
	}
	//进入测试模式
	if (MessageFlag[MSG_HARDWARE_TEST] == ON)
	{
		MessageFlag[MSG_HARDWARE_TEST] = OFF;
		ITULayer* Layer_TouchTest = ituSceneFindWidget(&theScene, "Layer_TouchTest");
		assert(Layer_TouchTest);
		ituLayerGoto(Layer_TouchTest);
	}
	//切换彩单类型
	if (MessageFlag[MSG_GUI_SWITCH_MAINMENU] == ON)
	{
		MessageFlag[MSG_GUI_SWITCH_MAINMENU] = OFF;
		GotoMainMenu();
	}
    return true;
}
bool PopupButton_MainMenu_On_Press(ITUWidget* widget, char* param)
{
	uint8_t PressKeyNum;
	PressKeyNum = atoi(param);
	if (PressKeyNum>30)
		return false;
	DisplayValue.TFT_Display_Device = PressKeyNum;
	MessageFlag[MSG_GET_DEVICE_STATE] = ON;
	MessageFlag[MSG_GET_DEVICE_CONFIG] = ON;
	GotoLayerByKetVol(DisplayValue.TFT_Display_Device);
	return true;
}
//根据序号跳转界面或执行对应场景
void GotoLayerByKetVol(uint8_t DeviceKeyVol)
{
	uint16_t nType;
	ITULayer *Layer;
	if (TFT_Device[DeviceKeyVol].DeviceEventType == 1)//设备
	{
		nType = TFT_Device[DeviceKeyVol].TFTSCEQ.TFT_Device.DeviceType;
		switch (nType)
		{
		case DEVIC_TYPE_LIGHT://普通灯
		case DEVIC_TYPE_LIGHT_KNX://普通灯
		case DEVIC_TYPE_LIGHT_ZIGBEE://Zigbee 普通灯
		case DEVIC_TYPE_GROUP_LIGHT://普通灯组
			Layer = ituSceneFindWidget(&theScene, "Layer_PTLight");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_CTLIGHT://CT灯带
		case DEVIC_TYPE_CTLIGHT1_ZIGBEE://Zigbee CT灯带
		case DEVIC_TYPE_CTLIGHT2_ZIGBEE://Zigbee CT灯带
		case DEVIC_TYPE_CTLIGHT3_ZIGBEE://Zigbee CT灯带
		case DEVIC_TYPE_CTLIGHT4_ZIGBEE://Zigbee CT灯带
		case DEVIC_TYPE_GROUP_CTLIGHT://CT灯带组
			Layer = ituSceneFindWidget(&theScene, "Layer_CCTLight");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_CTLIGHT_KNX://CT灯带
			Layer = ituSceneFindWidget(&theScene, "Layer_KNX_CCTLight");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_ADJUSTLIGHT://调光灯
		case DEVIC_TYPE_ADJUSTLIGHT_KNX://调光灯
		case DEVIC_TYPE_ADJUSTLIGHT1_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT2_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT3_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT4_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT5_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT6_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT7_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT8_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT9_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT10_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_RIGUANGDENG://日光灯
		case DEVIC_TYPE_GROUP_ADJUSTLIGHT://调光灯组
			Layer = ituSceneFindWidget(&theScene, "Layer_DimmingLight");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_TONINGLIGHT://调色灯
		case DEVIC_TYPE_TONINGLIGHT_KNX://调色灯
		case DEVIC_TYPE_RGBWLIGHT://RGBW灯
		case DEVIC_TYPE_RGBWLIGHT_KNX://RGBW灯
		case DEVIC_TYPE_GROUP_TONINGLIGHT://调色灯组
			Layer = ituSceneFindWidget(&theScene, "Layer_RGBLight");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_RGBCWLIGHT://RGBCW灯
		case DEVIC_TYPE_GROUP_RGBCW_HSB://RGBCW灯组
			Layer = ituSceneFindWidget(&theScene, "Layer_RGBCWLight");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_STANDARD_JCURTAIN://标准卷帘
		case DEVIC_TYPE_STANDARD_JCURTAIN_KNX://标准卷帘
		case DEVIC_TYPE_STANDARD_JCURTAIN1_ZIGBEE://Zigbee 标准卷帘
		case DEVIC_TYPE_STANDARD_JCURTAIN2_ZIGBEE://Zigbee 标准卷帘
		case DEVIC_TYPE_PUSH_WINDOW://标准型推窗机
			Layer = ituSceneFindWidget(&theScene, "Layer_Standard_JuanLian");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_MECHANICAL_JOURNEY_JCURTAIN://机械行程卷帘
		case DEVIC_TYPE_ELECTRONIC_AUTO_JCURTAIN://电子自动卷帘
		case DEVIC_TYPE_ELECTRONIC_MANUAL_JCURTAIN://电子手动卷帘
		case DEVIC_TYPE_CEILING_CURTAIN://天棚帘
		case DEVIC_TYPE_MECHANICAL_PUSH_WINDOW://机械行程推窗机
		case DEVIC_TYPE_ELECTRONIC_PUSH_WINDOW://电子行程推窗机
		case DEVIC_TYPE_VERTICAL_CURTAIN://垂直帘
		case DEVIC_TYPE_PUSHPULL_WINDOW://推拉窗
		case DEVIC_TYPE_PUSHPULL_WINDOW1_ZIGBEE://Zigbee推窗机
		case DEVIC_TYPE_PUSHPULL_WINDOW2_ZIGBEE://Zigbee推窗机
		case DEVIC_TYPE_JOURNEY_JCURTAIN_KNX://行程卷帘
		case DEVIC_TYPE_JOURNEY_JCURTAIN1_ZIGBEE://Zigbee行程卷帘
		case DEVIC_TYPE_JOURNEY_JCURTAIN2_ZIGBEE://Zigbee行程卷帘
		case DEVIC_TYPE_JOURNEY_JCURTAIN3_ZIGBEE://Zigbee行程卷帘
			Layer = ituSceneFindWidget(&theScene, "Layer_JuanLian");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_STANDARD_KCURTAIN://开合帘
		case DEVIC_TYPE_STANDARD_KCURTAIN_KNX://开合帘
			Layer = ituSceneFindWidget(&theScene, "Layer_Standard_KaiHeLian");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_GROUP_ROUTE_MOTOR://行程电机组
		case DEVIC_TYPE_JOURNEY_KCURTAIN://行程开合帘
		case DEVIC_TYPE_JOURNEY_KCURTAIN_KNX://行程开合帘
		case DEVIC_TYPE_JOURNEY_KCURTAIN1_ZIGBEE://Zigbee行程开合帘
		case DEVIC_TYPE_JOURNEY_KCURTAIN2_ZIGBEE://Zigbee行程开合帘
		case DEVIC_TYPE_JOURNEY_KCURTAIN3_ZIGBEE://Zigbee行程开合帘
		case DEVIC_TYPE_SLIDING_DOOR://平移门
			Layer = ituSceneFindWidget(&theScene, "Layer_KaiHeLian");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_ELECTRONIC_JOURNEY_BLIND://电子行程百叶帘
		case DEVIC_TYPE_MECHANICAL_JOURNEY_BLIND://机械行程百叶帘
		case DEVIC_TYPE_BLIND1_ZIGBEE://Zigbee 百叶帘
		case DEVIC_TYPE_BLIND2_ZIGBEE://Zigbee 百叶帘
		case DEVIC_TYPE_BLIND3_ZIGBEE://Zigbee 百叶帘
		case DEVIC_TYPE_GROUP_ANGLE_MOTOR://角度电机组
			Layer = ituSceneFindWidget(&theScene, "Layer_BaiYeLian");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_DREAM_CURTAIN://梦幻帘
			Layer = ituSceneFindWidget(&theScene, "Layer_Dream_Curtain");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_WAZZOR_MOTOR://瓦瑟电机
			Layer = ituSceneFindWidget(&theScene, "Layer_Wazzor_Menu");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_DALI_TIAOSE://DALI-RGB调色灯
			Layer = ituSceneFindWidget(&theScene, "Layer_DALIN_RGBTIAOSE");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_DALI_RGBW://DALI-RGBW
			Layer = ituSceneFindWidget(&theScene, "Layer_DALIN_RGBW");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_DALI_RGBCW://DALI-RGBCW
			Layer = ituSceneFindWidget(&theScene, "Layer_DALIN_RGBCW");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_GROUP_DALI_TIAOGUANG://DALI-调光灯
			Layer = ituSceneFindWidget(&theScene, "Layer_DALIN_TIAOGUANG");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_GROUP_DALI_TIAOSE://DALI-RGB调色灯
			Layer = ituSceneFindWidget(&theScene, "Layer_DALIN_RGBTIAOSE");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_GROUP_DALI_RGBW://DALI-RGBW
			Layer = ituSceneFindWidget(&theScene, "Layer_DALIN_RGBW");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_GROUP_DALI_RGBCW://DALI-RGBCW
			Layer = ituSceneFindWidget(&theScene, "Layer_DALIN_RGBCW");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_DALI_TIAOGUANG://DALI-调光灯
			Layer = ituSceneFindWidget(&theScene, "Layer_DALIN_TIAOGUANG");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_CDOAS://新风
		case DEVIC_TYPE_LZT_CDOAS://梁志天新风
		case DEVIC_TYPE_CDOAS1_ZIGBEE://Zigbee新风
		case DEVIC_TYPE_CDOAS2_ZIGBEE://Zigbee新风
		case DEVIC_TYPE_CDOAS3_ZIGBEE://Zigbee新风
		case DEVIC_TYPE_GROUP_CDOAS://新风组
			Layer = ituSceneFindWidget(&theScene, "Layer_Cdaos");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_HEAT://地暖
		case DEVIC_TYPE_LZT_HEAT://梁志天地暖
		case DEVIC_TYPE_HEAT1_ZIGBEE://Zigbee地暖
		case DEVIC_TYPE_HEAT2_ZIGBEE://Zigbee地暖
		case DEVIC_TYPE_HEAT3_ZIGBEE://Zigbee地暖
		case DEVIC_TYPE_GROUP_HEAT://地暖组
			Layer = ituSceneFindWidget(&theScene, "Layer_Heat");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_AIRCONDITION://空调
		case DEVIC_TYPE_LZT_AIRCONDITION://梁志天空调
		case DEVIC_TYPE_MATCH_CODE_AIRCONDITION://对码型空调
		//case DEVIC_TYPE_CODING_AIRCONDITION://编码型空调
		case DEVIC_TYPE_AIRCONDITION1_ZIGBEE://Zigbee空调
		case DEVIC_TYPE_AIRCONDITION2_ZIGBEE://Zigbee空调
		case DEVIC_TYPE_AIRCONDITION3_ZIGBEE://Zigbee空调
		case DEVIC_TYPE_AIRCONDITION4_ZIGBEE://Zigbee空调
		case DEVIC_TYPE_GROUP_AIRCONDITION://空调组
			Layer = ituSceneFindWidget(&theScene, "Layer_KongTiao");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_DX_HEAT://毛细温控器（德性毛细地暖）
			Layer = ituSceneFindWidget(&theScene, "Layer_MaoXiKongTiao");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_ZNZX_HEAT://毛细温控器（中南中心毛细地暖）
			Layer = ituSceneFindWidget(&theScene, "Layer_ZNZX_MaoXiKongTiao");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_GROUP_TV: //电视
			Layer = ituSceneFindWidget(&theScene, "Layer_TV");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		case DEVIC_TYPE_GROUP_BACKMUSIC://背景音乐组
		case DEVIC_TYPE_THIRD_BACKMUSIC://第三方背景音乐
		case DEVIC_TYPE_DOOYA_BACKMUSIC://dooya背景音乐
		case DEVIC_TYPE_YODOR_BACKMUSIC://优达背景音乐
		case DEVIC_TYPE_BACKAUDIO_BACKMUSIC://泊声背景音乐
		case DEVIC_TYPE_BACKAUDIO_485_BACKMUSIC://泊声485背景音乐
		case DEVIC_TYPE_YIJIA_BACKMUSIC://亿佳背景音乐
		case DEVIC_TYPE_HOPE_BACKMUSIC:	//向往背景音乐
			Layer = ituSceneFindWidget(&theScene, "Layer_BackMusic");
			assert(Layer);
			ituLayerGoto(Layer);
			break;
		default:
			break;
		}
	}
	else if (TFT_Device[DisplayValue.TFT_Display_Device].DeviceEventType == 2 || TFT_Device[DisplayValue.TFT_Display_Device].DeviceEventType == 3)//场景/序列
	{
		Layer = ituSceneFindWidget(&theScene, "Layer_SceneConfirm");
		assert(Layer);
		ituLayerGoto(Layer);
	}
	else if (TFT_Device[DisplayValue.TFT_Display_Device].DeviceEventType == 4)//清洁模式
	{
		Layer = ituSceneFindWidget(&theScene, "Layer_CleanMode");
		assert(Layer);
		ituLayerGoto(Layer);
	}
	else
	{

	}
}
//根据序号获取设备的状态文本
char* GetText_DeviceState(uint8_t DeviceKeyVol,char* StateText)
{
	char TempText[40] = "";
	uint16_t nType;
	if (TFT_Device[DeviceKeyVol].DeviceEventType == 1)//当前按钮为设备类型
	{
		nType = TFT_Device[DeviceKeyVol].TFTSCEQ.TFT_Device.DeviceType;
		switch (nType)
		{
		case DEVIC_TYPE_LIGHT://普通灯
		case DEVIC_TYPE_LIGHT_KNX://普通灯
		case DEVIC_TYPE_LIGHT_ZIGBEE://Zigbee 普通灯
		case DEVIC_TYPE_GROUP_LIGHT://普通灯组
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 1)
				strcpy(StateText, "ON");
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_ADJUSTLIGHT:
		case DEVIC_TYPE_ADJUSTLIGHT_KNX://调光灯
		case DEVIC_TYPE_ADJUSTLIGHT1_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT2_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT3_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT4_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT5_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT6_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT7_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT8_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT9_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_ADJUSTLIGHT10_ZIGBEE://Zigbee 调光灯
		case DEVIC_TYPE_RIGUANGDENG://日光灯
		case DEVIC_TYPE_GROUP_ADJUSTLIGHT://调光灯组
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 1)
			{
				itoa(TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.data[0], StateText, 10);
				strcat(StateText, "%");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_CTLIGHT:
		case DEVIC_TYPE_CTLIGHT_KNX:
		case DEVIC_TYPE_CTLIGHT1_ZIGBEE://Zigbee CT灯带
		case DEVIC_TYPE_CTLIGHT2_ZIGBEE://Zigbee CT灯带
		case DEVIC_TYPE_CTLIGHT3_ZIGBEE://Zigbee CT灯带
		case DEVIC_TYPE_CTLIGHT4_ZIGBEE://Zigbee CT灯带
		case DEVIC_TYPE_GROUP_CTLIGHT://CT灯带组
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 1)
			{
				itoa(TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.data[1], StateText, 10);
				strcat(StateText, "%");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_TONINGLIGHT://调色灯
		case DEVIC_TYPE_TONINGLIGHT_KNX://调色灯
		case DEVIC_TYPE_RGBWLIGHT://RGBW灯
		case DEVIC_TYPE_RGBCWLIGHT://RGBCW灯
		case DEVIC_TYPE_GROUP_RGBCW_HSB://RGBCW灯组
		case DEVIC_TYPE_RGBWLIGHT_KNX://RGBW灯
		case DEVIC_TYPE_GROUP_TONINGLIGHT://调色灯组
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 1)
			{
				strcpy(StateText, "ON");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_MECHANICAL_JOURNEY_JCURTAIN://机械行程卷帘
		case DEVIC_TYPE_ELECTRONIC_AUTO_JCURTAIN://电子自动卷帘
		case DEVIC_TYPE_ELECTRONIC_MANUAL_JCURTAIN://电子手动卷帘
		case DEVIC_TYPE_CEILING_CURTAIN://天棚帘
		case DEVIC_TYPE_JOURNEY_KCURTAIN://行程开合帘
		case DEVIC_TYPE_JOURNEY_KCURTAIN_KNX://行程开合帘
		case DEVIC_TYPE_JOURNEY_KCURTAIN1_ZIGBEE://Zigbee行程开合帘
		case DEVIC_TYPE_JOURNEY_KCURTAIN2_ZIGBEE://Zigbee行程开合帘
		case DEVIC_TYPE_JOURNEY_KCURTAIN3_ZIGBEE://Zigbee行程开合帘
		case DEVIC_TYPE_MECHANICAL_PUSH_WINDOW://机械行程推窗机
		case DEVIC_TYPE_ELECTRONIC_PUSH_WINDOW://电子行程推窗机
		case DEVIC_TYPE_VERTICAL_CURTAIN://垂直帘
		case DEVIC_TYPE_SLIDING_DOOR://平移门
		case DEVIC_TYPE_PUSH_WINDOW://标准型推窗机
		case DEVIC_TYPE_PUSHPULL_WINDOW://推拉窗
		case DEVIC_TYPE_PUSHPULL_WINDOW1_ZIGBEE://Zigbee推窗机
		case DEVIC_TYPE_PUSHPULL_WINDOW2_ZIGBEE://Zigbee推窗机
		case DEVIC_TYPE_JOURNEY_JCURTAIN_KNX://行程卷帘
		case DEVIC_TYPE_JOURNEY_JCURTAIN1_ZIGBEE://Zigbee行程卷帘
		case DEVIC_TYPE_JOURNEY_JCURTAIN2_ZIGBEE://Zigbee行程卷帘
		case DEVIC_TYPE_JOURNEY_JCURTAIN3_ZIGBEE://Zigbee行程卷帘
		case DEVIC_TYPE_GROUP_ROUTE_MOTOR://行程电机组
			itoa(TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Motor_Status.route, StateText, 10);
			strcat(StateText, "%");
			break;
		case DEVIC_TYPE_ELECTRONIC_JOURNEY_BLIND://电子行程百叶帘
		case DEVIC_TYPE_MECHANICAL_JOURNEY_BLIND://机械行程百叶帘
		case DEVIC_TYPE_BLIND1_ZIGBEE://Zigbee 百叶帘
		case DEVIC_TYPE_BLIND2_ZIGBEE://Zigbee 百叶帘
		case DEVIC_TYPE_BLIND3_ZIGBEE://Zigbee 百叶帘
		case DEVIC_TYPE_GROUP_ANGLE_MOTOR://角度电机组
		case DEVIC_TYPE_DREAM_CURTAIN://梦幻帘
			itoa(TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Motor_Status.route, StateText, 10);
			strcat(StateText, "% ");
			itoa(TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Motor_Status.angle, TempText, 10);
			strcat(StateText, TempText);
			strcat(StateText, "°");
			break;
		case DEVIC_TYPE_WAZZOR_MOTOR://瓦瑟电机
			itoa(TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Motor_Status.route, StateText, 10);
			strcat(StateText, "% ");
			break;
		case DEVIC_TYPE_DALI_TIAOSE://DALI-RGB调色灯
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 1)
			{
				strcpy(StateText, "ON");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_DALI_RGBW://DALI-RGBW
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 1)
			{
				strcpy(StateText, "ON");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_DALI_RGBCW://DALI-RGBCW
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 1)
			{
				strcpy(StateText, "ON");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_DALI_TIAOGUANG://DALI-调光灯
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 1)
			{
				strcpy(StateText, "ON");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_GROUP_DALI_TIAOSE://DALI-RGB调色灯
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 1)
			{
				strcpy(StateText, "ON");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_GROUP_DALI_RGBW://DALI-RGBW
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 1)
			{
				strcpy(StateText, "ON");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_GROUP_DALI_RGBCW://DALI-RGBCW
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 1)
			{
				strcpy(StateText, "ON");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_GROUP_DALI_TIAOGUANG://DALI-调光灯
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 1)
			{
				strcpy(StateText, "ON");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Light_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_CDOAS://新风
		case DEVIC_TYPE_LZT_CDOAS://梁志天新风
		case DEVIC_TYPE_CDOAS1_ZIGBEE://Zigbee新风
		case DEVIC_TYPE_CDOAS2_ZIGBEE://Zigbee新风
		case DEVIC_TYPE_CDOAS3_ZIGBEE://Zigbee新风
		case DEVIC_TYPE_GROUP_CDOAS://新风组
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Cdaos_Status.status == 1)
				strcpy(StateText, "ON");
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Cdaos_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_HEAT://地暖
		case DEVIC_TYPE_LZT_HEAT://梁志天地暖
		case DEVIC_TYPE_HEAT1_ZIGBEE://Zigbee地暖
		case DEVIC_TYPE_HEAT2_ZIGBEE://Zigbee地暖
		case DEVIC_TYPE_HEAT3_ZIGBEE://Zigbee地暖
		case DEVIC_TYPE_GROUP_HEAT://地暖组
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Heat_Status.status == 1)
			{
				itoa(TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Heat_Status.Set_Temp / 2, StateText, 10);
				strcat(StateText, "°");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Heat_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_AIRCONDITION:
		case DEVIC_TYPE_LZT_AIRCONDITION://梁志天空调
		case DEVIC_TYPE_MATCH_CODE_AIRCONDITION://对码型空调
		//case DEVIC_TYPE_CODING_AIRCONDITION://编码型空调
		case DEVIC_TYPE_AIRCONDITION1_ZIGBEE://Zigbee空调
		case DEVIC_TYPE_AIRCONDITION2_ZIGBEE://Zigbee空调
		case DEVIC_TYPE_AIRCONDITION3_ZIGBEE://Zigbee空调
		case DEVIC_TYPE_AIRCONDITION4_ZIGBEE://Zigbee空调
		case DEVIC_TYPE_GROUP_AIRCONDITION://空调组
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Air_Status.status == 1)
			{
				itoa(TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Air_Status.Set_Temp / 2, StateText, 10);
				strcat(StateText, "°");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_Air_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		case DEVIC_TYPE_DX_HEAT:
		case DEVIC_TYPE_ZNZX_HEAT:
			if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_DX_Heat_Status.status == 1)
			{
				itoa(TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_DX_Heat_Status.Set_Temp / 10, StateText, 10);
				strcat(StateText, "°");
			}
			else if (TFT_Device_State[DeviceKeyVol].IT_Dev_STatus_Value.IT_DX_Heat_Status.status == 0)
				strcpy(StateText, "OFF");
			break;
		default:
			strcpy(StateText, "");
			break;
		}
	}
	else
	{
		strcpy(StateText, "");
	}
	return StateText;
}

